<template>
	<view>
		<view class="cu-list grid" :class="['col-' + cols, gridBorder ? '' : 'no-border']">
			<view class="cu-item" v-for="(item, index) in datas" :key="index" @click="onClick" :data-index="index">
				<view v-if="item.cuIcon" :class="['cuIcon-' + item.cuIcon, 'text-' + item.color]">
					<view class="cu-tag badge" v-if="item.badge >0">
						<block v-if="item.badge != 1">{{ item.badge > 99 ? '99+' : item.badge }}</block>
					</view>
				</view>
				<text v-if="item.name">{{ item.name }}</text>
				<text v-if="item.value">{{ item.value }}</text>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {};
	},
	name: 'cu-custom',
	computed: {
		style() {
			var style = '';
			return style;
		}
	},
	props: {
		datas: Array,
		cols:  {
			type: [Number,String],
			default: 3
		},
		gridBorder: {
			type: [Boolean, String],
			default: false
		}
	},
	methods: {
		onClick(e) {
			// let index=e.currentTarget.dataset.index
			// this.$emit('onchange', index);
			var index = e.currentTarget.dataset.index;
			if(this.datas.length<=index){
				this.$util.showAlert("缺少跳转路径");
				return;
			}
			let item=this.datas[index];
			//console.log(good)
			if(!item.path){
				//this.$util.showAlert("缺少跳转路径");
				 this.$emit('onchange', index);
				return;
			}
			this.$util.redirectTo(item.path,item);
		}
	}
};
</script>

<style scoped></style>
